<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 4. <对象(映射)&数组练习>转换数组
        const mapping = {
            shengjian: '生煎',
            baozi: '灌汤包',
            jiaozi: '水饺',
            burger: '汉堡',
        };
        const input = [
            {
                label: 'shengjian',
                value: 'shengjian',
            },
            {
                label: 'baozi',
                value: 'baozi',
            },
            {
                label: 'jiaozi',
                value: 'jiaozi',
            },
            {
                label: 'burger',
                value: 'burger',
            },
        ];
        const output = [
            {
                label: '生煎',
                value: 'shengjian',
            },
            {
                label: '灌汤包',
                value: 'baozi',
            },
            {
                label: '水饺',
                value: 'jiaozi',
            },
            {
                label: '汉堡',
                value: 'burger',
            },
        ];

        // ⭐
        function transform(input, mapping) {
            return input.map((item) => ({
                ...item,
                label: mapping[item.label],// mapping['shengjian']
            }))
        }
        console.log(transform(input, mapping));
    </script>
</body>
</html>